package cn.itcast.bos.transit.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.domain.transit.SignInfo;
import cn.itcast.bos.domain.transit.TransitInfo;
import cn.itcast.bos.transit.dao.SignInfoDao;
import cn.itcast.bos.transit.dao.TransitInfoDao;
import cn.itcast.bos.transit.service.SignInfoServcie;

@Service
@Transactional
public class SignInfoServiceImpl implements SignInfoServcie{
	@Autowired
	private SignInfoDao signInfoDao;
	@Autowired
	private TransitInfoDao transitInfoDao; 
	
	@Override
	public void save(SignInfo t) {
		// TODO Auto-generated method stub
		TransitInfo transitInfo = transitInfoDao.getOne(t.getId());
		if(transitInfo.getStatus().equals("开始配送")){
			t.setId(null);
			SignInfo signInfo = signInfoDao.save(t);
			transitInfo.setSignInfo(t);
			transitInfo.setStatus("正常签收");
			transitInfo.getWayBill().setSignStatus(3);
		}else{
			throw new RuntimeException("无配送信息");
		}
	}

}
